import { Button, NavBar } from 'antd-mobile'
import React from 'react'
import { useLocation } from 'react-router-dom'
import { useNavigate } from 'react-router-dom'
import utils from '../../utils/index'
const Deail = () => {
    const navigate = useNavigate()
    const { state } = useLocation()
    console.log(state);
    
    const zhifu=async()=>{
        console.log("支付");
        const id= new Date().getTime()
        const resp=await utils.get('/pay',{params:{title:"火车票",id:id,price:1000}})
        window.open(resp.data.data)
    }
    return (
        <div>

            <NavBar onBack={() => navigate(-1)}>详情</NavBar>
            <div>
                <dl style={{
                    display: 'flex',
                    justifyContent: 'space-around',
                    padding: '10px'
                }}
                >
                    <dt>
                        {state.start}-{state.end}
                        <div>时间:{state.startTime}</div>
                    </dt>
                    <dd>
                        <div>是否高铁:{state.isSeat ? '非高铁' : '高铁'}</div>
                        <div>是否有票:{state.isSpeed ? '无票' : '有票'}</div>
                    </dd>
                    <dd>
                        <div>商务座:{state.tick.vip}</div>
                        <div>一等座:{state.tick.firstTick}</div>
                        <div>二等座:{state.tick.secondTick}</div>
                    </dd>
                </dl>
            </div>
            <Button block color='primary' onClick={() =>zhifu()}>支付</Button>
        </div>
    )
}

export default Deail
